<?php
declare(strict_types=1);


namespace App\Hoenix\Mapper;

use App\Hoenix\Model\HoenixConcubine;
use Hyperf\Database\Model\Builder;
use Mine\Abstracts\AbstractMapper;

/**
 * 服务人员列表Mapper类
 */
class HoenixConcubineMapper extends AbstractMapper
{
    /**
     * @var HoenixConcubine
     */
    public $model;

    public function assignModel()
    {
        $this->model = HoenixConcubine::class;
    }

    /**
     * 搜索处理器
     * @param Builder $query
     * @param array $params
     * @return Builder
     */
    public function handleSearch(Builder $query, array $params): Builder
    {
        
        // 主键
        if (isset($params['id']) && filled($params['id'])) {
            $query->where('id', '=', $params['id']);
        }

        // 0散单1包养/长期
        if (isset($params['type']) && filled($params['type'])) {
            $query->where('type', '=', $params['type']);
        }

        // 
        if (isset($params['created_at']) && filled($params['created_at']) && is_array($params['created_at']) && count($params['created_at']) == 2) {
            $query->whereBetween(
                'created_at',
                [ $params['created_at'][0], $params['created_at'][1] ]
            );
        }

        // 
        if (isset($params['updated_at']) && filled($params['updated_at']) && is_array($params['updated_at']) && count($params['updated_at']) == 2) {
            $query->whereBetween(
                'updated_at',
                [ $params['updated_at'][0], $params['updated_at'][1] ]
            );
        }

        // 罩杯
        if (isset($params['cup']) && filled($params['cup'])) {
            $query->where('cup', '=', $params['cup']);
        }

        // 处0否1是
        if (isset($params['virgin']) && filled($params['virgin'])) {
            $query->where('virgin', '=', $params['virgin']);
        }

        // 口0否1是
        if (isset($params['oral_sex']) && filled($params['oral_sex'])) {
            $query->where('oral_sex', '=', $params['oral_sex']);
        }

        // 套0否1是
        if (isset($params['condom']) && filled($params['condom'])) {
            $query->where('condom', '=', $params['condom']);
        }

        // 内0否1是
        if (isset($params['injection']) && filled($params['injection'])) {
            $query->where('injection', '=', $params['injection']);
        }

        // 文身0否1是
        if (isset($params['tattoo']) && filled($params['tattoo'])) {
            $query->where('tattoo', '=', $params['tattoo']);
        }

        // 同居0否1是
        if (isset($params['cohabitation']) && filled($params['cohabitation'])) {
            $query->where('cohabitation', '=', $params['cohabitation']);
        }

        // 过夜0否1是
        if (isset($params['make_love']) && filled($params['make_love'])) {
            $query->where('make_love', '=', $params['make_love']);
        }

        // 可飞0否1是
        if (isset($params['flyable']) && filled($params['flyable'])) {
            $query->where('flyable', '=', $params['flyable']);
        }

        // 外地0否1是
        if (isset($params['other_places']) && filled($params['other_places'])) {
            $query->where('other_places', '=', $params['other_places']);
        }

        // 0否1是2轻微
        if (isset($params['sm']) && filled($params['sm'])) {
            $query->where('sm', '=', $params['sm']);
        }

        // 1接单2不接单3服务中
        if (isset($params['status']) && filled($params['status'])) {
            $query->where('status', '=', $params['status']);
        }

        // 陪伴天数
        if (isset($params['accompany_day']) && filled($params['accompany_day'])) {
            $query->where('accompany_day', 'like', '%'.$params['accompany_day'].'%');
        }

        // 雷点
        if (isset($params['trigger_point']) && filled($params['trigger_point'])) {
            $query->where('trigger_point', 'like', '%'.$params['trigger_point'].'%');
        }

        // 经期
        if (isset($params['menstrual_period']) && filled($params['menstrual_period'])) {
            $query->where('menstrual_period', 'like', '%'.$params['menstrual_period'].'%');
        }

        // 工资
        if (isset($params['wages']) && filled($params['wages'])) {
            $query->where('wages', '=', $params['wages']);
        }

        // 次数
        if (isset($params['wages_times']) && filled($params['wages_times'])) {
            $query->where('wages_times', '=', $params['wages_times']);
        }

        // 原因
        if (isset($params['reason']) && filled($params['reason'])) {
            $query->where('reason', 'like', '%'.$params['reason'].'%');
        }

        // 到岗
        if (isset($params['on_duty']) && filled($params['on_duty'])) {
            $query->where('on_duty', 'like', '%'.$params['on_duty'].'%');
        }

        // 介绍
        if (isset($params['self_intro']) && filled($params['self_intro'])) {
            $query->where('self_intro', 'like', '%'.$params['self_intro'].'%');
        }

        // 希望
        if (isset($params['hope']) && filled($params['hope'])) {
            $query->where('hope', 'like', '%'.$params['hope'].'%');
        }

        // 
        if (isset($params['view']) && filled($params['view'])) {
            $query->where('view', '=', $params['view']);
        }

        // 
        if (isset($params['sort']) && filled($params['sort'])) {
            $query->where('sort', '=', $params['sort']);
        }

        // 
        if (isset($params['image']) && filled($params['image'])) {
            $query->where('image', '=', $params['image']);
        }

        // 
        if (isset($params['video']) && filled($params['video'])) {
            $query->where('video', '=', $params['video']);
        }

        // 用户id
        if (isset($params['user_id']) && filled($params['user_id'])) {
            $query->where('user_id', '=', $params['user_id']);
        }

        return $query;
    }
}